// component/ModalContainerComponent/ModalContainerComponent.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    showMode: {
      type: String,
      value: "normal"
    },
    cancelText: {
      type: String,
      value: "取消"
    },
    confirmText: {
      type: String,
      value: "确定"
    },
    height: {
      type: String,
      value: "580"
    }
  },
  

  /**
   * 组件的初始数据
   */
  data: {
    bgAnim: {}, // 背景动画
    contentAnim: {} // 内容动画
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 取消
     */
    cancel: function(e) {
      var _this = this;
      this.exitAnim(function() {
        _this.triggerEvent('onCancel', {})
      });
    },

    /**
     * 确定
     */
    confirm: function(e) {
      var _this = this;
      this.exitAnim(function() {
        _this.triggerEvent('onConfirm', {})
      });
    },

    /**
     * 退出动画
     */
    exitAnim: function(onFinish) {
      let anim = wx.createAnimation({});
      anim.opacity(0).step();
      let anim2 = wx.createAnimation({});
      anim2.scale(0.1).step();
      this.setData({
        bgAnim: anim.export(),
        contentAnim: anim2.export()
      }, e => {
        setTimeout(function() {
          onFinish();
        },1000)
      })
    }
  }

})
